package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.xcity.db.entity.Employee;
import com.xcity.db.entity.Player;
import com.xcity.game.employee.EmployeeService;
import com.xcity.game.employee.config.impl.EmployeeStarLevelUpConfigure;
import com.xcity.game.employee.response.EmployeeLevelUpRequired;
import com.xcity.game.employee.template.EmployeeStarUpTemplate;
import com.xcity.game.item.ItemInfo;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class EmployeeStarUpInfoResponse extends Response {
	
	private long id;
	private int starLvl;
	private int starMaxLvl;
	private List<ItemInfo> items = Collections.emptyList(); // 需求物品
	private List<ItemInfo> cards = Collections.emptyList(); // 需求卡牌
	private long gold;
	
	public EmployeeStarUpInfoResponse(int serial, Player player, Employee employee, EmployeeService service) {
		super(serial);
		this.id = employee.getId();
		this.starLvl = employee.getStarLvl();
		EmployeeStarLevelUpConfigure configure = service.configure().getStarLevelUpConfigure();
		this.starMaxLvl = configure.getMaxLevel(employee);
		EmployeeStarUpTemplate template = configure.getNextLevelTemplate(employee);
		if (template != null) {
			if (template.getItemId() != 0 && template.getItemCount() > 0) {
				this.items = Arrays.asList(new EmployeeLevelUpRequired(template.getItemId(), template.getItemCount(), player));
			}
			this.cards = new ArrayList<ItemInfo>(2);
			ItemInfo mainCard = EmployeeStarLevelUpConfigure.getWrappedMainCard(player, employee, template); // 主卡
			if (mainCard != null) {
				this.cards.add(mainCard);
			}
			ItemInfo viceCard = EmployeeStarLevelUpConfigure.getWrappedViceCard(player, employee, template); // 副卡
			if (viceCard != null) {
				this.cards.add(viceCard);
			}
			this.gold = template.getGold();
		}
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getStarLvl() {
		return starLvl;
	}

	public void setStarLvl(int starLvl) {
		this.starLvl = starLvl;
	}

	public int getStarMaxLvl() {
		return starMaxLvl;
	}

	public void setStarMaxLvl(int starMaxLvl) {
		this.starMaxLvl = starMaxLvl;
	}

	public List<ItemInfo> getItems() {
		return items;
	}

	public void setItems(List<ItemInfo> items) {
		this.items = items;
	}

	public List<ItemInfo> getCards() {
		return cards;
	}

	public void setCards(List<ItemInfo> cards) {
		this.cards = cards;
	}

	public long getGold() {
		return gold;
	}

	public void setGold(long gold) {
		this.gold = gold;
	}
	
}
